package com.sprites;

import com.bricks2break.Player;
import com.bricks2break.Statics;
import com.events.DoublePointsEvent;

import android.graphics.Paint;

public class DoublePointsBrick extends AbstractSpecialBrick {

	/**
	 * Constructor
	 * @param paint
	 * @param value
	 * @param durationTime
	 */
	public DoublePointsBrick(Paint paint, int value, float durationTime) {
		super(paint,  value, durationTime);
	}

	/**
	 * Draw method
	 */
	public void draw(android.graphics.Canvas canvas) {
		//Calls super.draw to draw brick
		super.draw(canvas);
		//Draw text on top of brick
		canvas.drawText("2x points", getX() - getWidth() / 2 + 10, getY(), Statics.white);
	}

	@Override
	/**
	 * Method that adds a double points event to EventTimer, so the player get double points in a given duration
	 */
	public void addEvent(Object subject) {
		if (subject instanceof Ball) {
			Player p = ((Ball) subject).getCurrentOwner();
			Statics.eventTimer.addEvent(new DoublePointsEvent(getDurationTime(), p));
		}
	}
}
